package com.wharf.base.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import com.wharf.base.dao.GoodsMapper;
import com.wharf.base.dao.GoodsTypeMapper;
import com.wharf.base.model.AddGoods;
import com.wharf.base.model.Goods;
import com.wharf.base.model.GoodsType;

@Service
public class GoodsInfoServiceImpl implements GoodsInfoService{
	
	@Autowired
	private GoodsMapper goodsmapper;
	@Autowired
	private GoodsTypeMapper typeMapper;
	
	@Override
	public List<Goods> goodsShow() {
		List<Goods> list = goodsmapper.selectAllGoods();
		return list;
	}

	@Override
	public List<Goods> search(String goodsName) {
		List<Goods> search = goodsmapper.selectByName(goodsName);
		return search;
	}

	@Override
	public boolean insertGoods(AddGoods addGoods) {
		int i = goodsmapper.insertGoods(addGoods);
		if(i != 0) {
			return true;
		}
		return false;
	}

	@Override
	public boolean delById(Integer id) {
		int i = goodsmapper.delById(id);
		if(i != 0) {
			return true;
		}
		return false;
	}

	@Override
	public List<GoodsType> typeShow() {
		List<GoodsType> list = typeMapper.selectAll();
		return list;
	}

	@Override
	public boolean delTypeGoods(Integer id) {
		int i = typeMapper.delById(id);
		if(i != 0) {
			return true;
		}
		return false;
	}

}
